package cn.com.customer.manager.ui.order.list

import cn.com.customer.manager.bean.OrderListInfo
import cn.com.customer.manager.bean.RequestBean
import cn.com.customer.manager.bean.RequestOrder
import cn.com.customer.manager.http.BaseApi
import cn.com.customer.manager.http.subscriber.TipRequestSubscriber
import com.xuexiang.xhttp2.XHttp
import com.xuexiang.xhttp2.model.ApiResult

class OrderPresenter constructor(view:OrderContract.View) :OrderContract.Presenter {
    val mView:OrderContract.View=view
    val request = XHttp.custom()


    override fun getList(params:RequestOrder) {
        request.call(request.create(BaseApi.IOrder::class.java)
                .orderList(RequestBean(params)))
                .subscribeWith(object : TipRequestSubscriber<ApiResult<OrderListInfo>?>() {
                    override fun onSuccess(apiResult: ApiResult<OrderListInfo>?) {
                        apiResult?.let {
                            if (it != null) {
                                mView.setList(it.data)
                            }
                        }
                    }
                })

    }

    override fun start() {


    }
}